﻿using System;
using System.ComponentModel;
using Loki;
using Luna.Data;

namespace Luna.Model.Accounting
{
    internal class AccountingCategory : LunaEntity, IAccountingCategory
    {
        public Guid PK
        {
            get { return ID; }
            set { ID = value; }
        }

        #region  Name
        private static PropertyChangedEventArgs _NameChangeArgs = ObservableHelper.CreateArgs<AccountingCategory>(x => x.Name);

        private string _Name;

        public string Name
        {
            get
            {
                return _Name;
            }

            set
            {
                if (value != _Name)
                {
                    _Name = value;
                    NotifyChangedAndDirty(_NameChangeArgs);
                }
            }
        }
        #endregion

        #region  Description
        private static PropertyChangedEventArgs _DescriptionChangeArgs = ObservableHelper.CreateArgs<AccountingCategory>(x => x.Description);

        private string _Description;

        public string Description
        {
            get
            {
                return _Description;
            }

            set
            {
                if (value != _Description)
                {
                    _Description = value;
                    NotifyChangedAndDirty(_DescriptionChangeArgs);
                }
            }
        }
        #endregion

        internal AccountingCategory()
            : base()
        {
        }

        internal AccountingCategory(AccountingCategory P_User)
            : base((LunaEntity)P_User)
        {
            LoadData(P_User);
        }

        public AccountingCategory(INamedEntityData P_UserData)
            : base(P_UserData)
        {
            LoadData(P_UserData);
            AcceptChanges();
        }

        public void CopyValues(IAccountingCategory P_User)
        {
            Name = P_User.Name;
            Description = P_User.Description;
        }

        private void LoadData(INamedEntityData P_UserData)
        {
            _Name = P_UserData.Name;
            _Description = P_UserData.Description;
        }
    }
}
